package com.ruoyi.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.DayInventory;
import com.ruoyi.shop.service.IDayInventoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品日清Controller
 * 
 * @author ruoyi
 * @date 2024-06-08
 */
@RestController
@RequestMapping("/shop/date")
public class DayInventoryController extends BaseController
{
    @Autowired
    private IDayInventoryService dayInventoryService;

    /**
     * 查询商品日清列表
     */
    @PreAuthorize("@ss.hasPermi('shop:date:list')")
    @GetMapping("/list")
    public TableDataInfo list(DayInventory dayInventory)
    {
        startPage();
        List<DayInventory> list = dayInventoryService.selectDayInventoryList(dayInventory);
        return getDataTable(list);
    }

    @GetMapping("/list1")
    public TableDataInfo list1(DayInventory dayInventory)
    {

        List<DayInventory> list = dayInventoryService.selectDayInventoryList2(dayInventory);
        return getDataTable(list);
    }

    @GetMapping("/list3")
    public TableDataInfo list3(DayInventory dayInventory)
    {
        List<DayInventory> list = dayInventoryService.selectDayInventoryList3(dayInventory);
        return getDataTable(list);
    }

    @GetMapping("/list4")
    public TableDataInfo list4(DayInventory dayInventory)
    {
        List<DayInventory> list = dayInventoryService.selectDayInventoryList4(dayInventory);
        return getDataTable(list);
    }

    /**
     * 导出商品日清列表
     */
    @PreAuthorize("@ss.hasPermi('shop:date:export')")
    @Log(title = "商品日清", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DayInventory dayInventory)
    {
        List<DayInventory> list = dayInventoryService.selectDayInventoryList(dayInventory);
        ExcelUtil<DayInventory> util = new ExcelUtil<DayInventory>(DayInventory.class);
        util.exportExcel(response, list, "商品日清数据");
    }

    /**
     * 获取商品日清详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:date:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dayInventoryService.selectDayInventoryById(id));
    }

    /**
     * 新增商品日清
     */
    @PreAuthorize("@ss.hasPermi('shop:date:add')")
    @Log(title = "商品日清", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DayInventory dayInventory)
    {
        return toAjax(dayInventoryService.insertDayInventory(dayInventory));
    }

    /**
     * 修改商品日清
     */
    @PreAuthorize("@ss.hasPermi('shop:date:edit')")
    @Log(title = "商品日清", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DayInventory dayInventory)
    {
        return toAjax(dayInventoryService.updateDayInventory(dayInventory));
    }

    /**
     * 删除商品日清
     */
    @PreAuthorize("@ss.hasPermi('shop:date:remove')")
    @Log(title = "商品日清", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dayInventoryService.deleteDayInventoryByIds(ids));
    }
}
